package org.example.erp.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.example.erp.domain.Sales;
import org.example.erp.domain.SnTable;
import org.example.erp.service.impl.SnTableServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class SntableController {
    @Autowired
    private SnTableServiceImpl snTableService;

    @GetMapping("/SnCode/find")
    public DataResult findSalesOutbound(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage,
                                        @RequestParam(value = "pageSize",defaultValue = "1") Integer pageSize,
                                        @RequestParam(required = false) String materialProductCode,
                                        @RequestParam(required = false) String productName,
                                        @RequestParam(required = false) Integer snId,
                                        @RequestParam(required = false) String batchNumber){
        return DataResult.success(snTableService.findsn(currentPage, pageSize,materialProductCode, productName, snId, batchNumber));
    }





    @DeleteMapping("/SnCode/delete")
    public DataResult deleteLoginLog(@RequestBody List<Integer> ids) {
        if(ids.isEmpty()){
            snTableService.remove(null);
        }else{
            snTableService.removeByIds(ids);
        }
        return DataResult.success();
    }
    @PostMapping("/SnCode/insert")
    public DataResult addSnTable(@RequestBody SnTable snTable) {
        snTableService.save(snTable);
        return DataResult.success();
    }

}
